import { Router } from 'express';
import { UserController } from '../controllers/userController';
import { uploadAvatar, handleUploadError } from '../middleware/upload';

const router = Router();
const userController = new UserController();

// 用户管理路由
router.post('/', userController.createUser);
router.get('/', userController.getUserList);
router.get('/stats', userController.getUserStats);
router.get('/:id', userController.getUserById);
router.put('/:id', userController.updateUser);
router.delete('/:id', userController.deleteUser);
router.post('/batch-delete', userController.batchDeleteUsers);
router.patch('/:id/status', userController.updateUserStatus);

// 头像上传路由
router.post('/:id/avatar', uploadAvatar, handleUploadError, userController.uploadAvatar);

// 用户地址管理路由
router.get('/:id/addresses', userController.getUserAddresses);
router.post('/:id/addresses', userController.createUserAddress);
router.put('/:id/addresses/:addressId', userController.updateUserAddress);
router.delete('/:id/addresses/:addressId', userController.deleteUserAddress);
router.patch('/:id/addresses/:addressId/default', userController.setDefaultAddress);

export default router;